package com.alexgaoyh.MutiModule.Dubbo.RWSeperate.provider.read.manager.demo.oneWithMany.course;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.MutiModule.common.myPage.MyPageView;
import com.MutiModule.common.myPage.util.MyPageViewUtilss;
import com.MutiModule.common.vo.mybatis.pagination.Page;
import com.alexgaoyh.MutiModule.Dubbo.RWSeperate.api.manager.demo.oneWithMany.course.read.IOneWithManyCourseReadService;
import com.alexgaoyh.MutiModule.Dubbo.RWSeperate.persist.manager.demo.oneWithMany.course.OneWithManyCourse;
import com.alexgaoyh.MutiModule.Dubbo.RWSeperate.persist.manager.demo.oneWithMany.course.OneWithManyCourseExample;
import com.alexgaoyh.MutiModule.Dubbo.RWSeperate.persist.manager.demo.oneWithMany.course.OneWithManyCourseMapper;
import com.alexgaoyh.MutiModule.Dubbo.RWSeperate.persist.manager.demo.oneWithMany.view.CourseStudentView;

@Service(value = "oneWithManyCourseService")
public class OneWithManyCourseServiceImpl implements IOneWithManyCourseReadService{
	
	@Resource(name = "oneWithManyCourseMapper")
	private OneWithManyCourseMapper mapper;

	@Override
	public int countByExample(OneWithManyCourseExample example) {
		return mapper.countByExample(example);
	}

	@Override
	public List<OneWithManyCourse> selectByExample(OneWithManyCourseExample example) {
		return mapper.selectByExample(example);
	}

	@Override
	public OneWithManyCourse selectByPrimaryKey(Long id) {
		return mapper.selectByPrimaryKey(id);
	}
	
	@Override
	public MyPageView<OneWithManyCourse> generateMyPageViewVO(OneWithManyCourseExample exampleWithOutPage, Page page) {
		
		int _totalCount = mapper.countByExample(exampleWithOutPage);
		
		exampleWithOutPage.setPage(page);
		
		List<OneWithManyCourse> _list = mapper.selectByExample(exampleWithOutPage);
		
		MyPageView<OneWithManyCourse> pageView = new MyPageViewUtilss<OneWithManyCourse>().generaterMyPageView(page.getLength(), page.getPageNo(), _totalCount, _list);
		
		return pageView;
	}

	@Override
	public List<CourseStudentView> selectCourseWithStudentByExample(OneWithManyCourseExample example) {
		return mapper.selectCourseWithStudentByExample(example);
	}

	@Override
	public MyPageView<CourseStudentView> generateMyPageViewVOWithStudent(OneWithManyCourseExample exampleWithOutPage,
			Page page) {
		int _totalCount = mapper.countByExample(exampleWithOutPage);
		
		exampleWithOutPage.setPage(page);
		
		List<CourseStudentView> _list = mapper.selectCourseWithStudentByExample(exampleWithOutPage);
		
		MyPageView<CourseStudentView> pageView = new MyPageViewUtilss<OneWithManyCourse>().generaterMyPageView(page.getLength(), page.getPageNo(), _totalCount, _list);
		
		return pageView;
	}

}
